package top.toptimus.dto.stock.ortherStockIn;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * 盘点入库和退货入库DTO
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderStockInDTO {
    private String orderId; //  id
    private String stockInType; //  出入库类型
    private Date stockInDate;   //  入库时间
    private List<OrderStockInEntryDTO> orderStockInEntryDTOS;

    /**
     * 核算入库加权平均价格
     *
     * @return this
     */
    public OrderStockInDTO build() {
        for (OrderStockInEntryDTO orderStockInEntryDTO : this.orderStockInEntryDTOS) {
            orderStockInEntryDTO.setStockInUnitPrice(orderStockInEntryDTO.getStockInPrice());
        }
        return this;
    }
}
